#!/bin/bash

dline=0 
for d in $(ls -1d eu*)
do
   dline=$(($dline+1))
   echo $dline " " $d 
done

echo "Type the number of the folder :"
read n
echo "you typed "$n

get_command(){
   if [ -z "$1" ]                           # Is parameter #1 zero length?
   then
     echo "-Parameter #1 is zero length.-"  # Or no parameter passed.
   else
     JAR=$(find $1/target -maxdepth 1 -type f \( ! -iname ".*" \))
     echo -e "install file:"$(pwd)/$JAR
   fi
}

dline=0
commands=""
for d in $(ls -1d eu*)
do
    dline=$(($dline+1))
    if [ $n -eq 0 ] ; then
    	echo "Now project : " $d
    	sleep 0.2
	( cd $d && mvn clean install ) 
	commands=$(get_command $d)"\n"$commands
    else
	
    	if [ $dline -eq $n ] ; then
     	  	echo "You have chosen project : " $d
        	sleep 0.1
		( cd $d && mvn clean install ) 
		get_command $d
    	fi            
    fi
done

if [ $n -eq 0 ] ; then
	echo -e $commands
fi



